<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@ include file="/WEB-INF/jsp/include/taglibs.jspf" %>
<decorator:usePage id="pageContent" />
<fmt:setBundle basename="StripesResources"/>
<%
    boolean front = (request.getRequestURI().indexOf("/login.jsp") > 0); //Hack! main page!!            
    pageContext.setAttribute("front", front, pageContext.PAGE_SCOPE);

    boolean home = (request.getRequestURI().indexOf("/home.jsp") > 0); //Hack! main page!!            
    pageContext.setAttribute("home", home, pageContext.PAGE_SCOPE);
%>
<!DOCTYPE html>
<html>
    <head>
        <title>Marine Audit & Task System</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <!-- CSS -->
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/social-icons.css" type="text/css" media="screen" />
        <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/loginstyle.css" />
        <!--[if IE 8]>
         <link rel="stylesheet" type="text/css" media="screen" href="css/ie8-hacks.css" />
 <![endif]-->
        <!-- ENDS CSS -->
        <!-- GOOGLE FONTS 
        <link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>-->
        <!-- JS -->
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.9.1.js"></script>
<!--        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.13.custom.min.js"></script>-->

        <%--script type="text/javascript" src="<%=request.getContextPath()%>/js/easing.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.scrollTo-1.4.2-min.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.cycle.all.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/custom.js"></script--%>
        <!-- Isotope -->
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.blockUI.js"></script> 
        <script src="<%=request.getContextPath()%>/js/jquery.isotope.min.js"></script>        <!-- tabs -->
        <!-- superfish -->        
        <link rel="stylesheet" media="screen" href="${pageContext.request.contextPath}/css/superfish.css" /> 
        <!--<link rel="stylesheet" media="screen" href="${pageContext.request.contextPath}/css/superfish-left.css" />--> 

        <script type="text/javascript" src="<%=request.getContextPath()%>/js/superfish-1.4.8/js/hoverIntent.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/superfish-1.4.8/js/superfish.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/superfish-1.4.8/js/supersubs.js"></script>


        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ui-lightness/jquery-ui-1.10.2.custom.css" />        
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-ui-1.10.2.custom.js"></script>      
        <script language="JavaScript" src="${pageContext.request.contextPath}/js/smartDate.js" type="text/javascript"></script>
        <script type="text/javascript">
            // took first loading time
            var currentDate = new Date();
            var timerStartLoad = currentDate.getTime();
            
            $(document).ready(function() {
                $("#datepicker").datepicker({
                    showOn: "button",
                    buttonImage: "${pageContext.request.contextPath}/images/icon/calendar.gif",
                    buttonImageOnly: true,
                    changeMonth: true,
                    changeYear: true,
                    dateFormat: 'dd/mm/yy',
                    maxDate: new Date()
                });
                $('.uppercase').each(function() {
                    $(this).blur(function() {
                        $(this).val($(this).val().toUpperCase());
                    });
                });

                $('.clear').each(function() {
                    $(this).click(function() {
                        $('.clearAll').each(function() {
                            $(this).val('');
                        });
                    });
                });

                $("ul#nav li").attr("onclick", "return true");
                $('#loading-img').hide();

                $('form').submit(function() {

                });

            });

        </script>
        <decorator:head />  
    </head>
    <body class="home">
        <div id="header">
            <div class="wrapper">
                <br>
                <br>
                <a href="welcome"><img id="logo" src="${pageContext.request.contextPath}/images/logo.png" alt="Marine Audit & Task System" /></a>
            </div>
        </div>           
        <c:if test="${!front}">
            <div id="menu">
                <div id="menu-holder">
                    <div class="wrapper">
                        <ul id="nav" class="sf-menu">
                            <li class="${fn:contains(pageContext.request.requestURI, '/home') ? 'current-menu-item' : ''}"><a href="welcome">Home</a></li>
                                <c:if test="${!empty actionBean.context.currentUser}">
                                    <c:set var="admin" value="false"/>
                                    <c:set var="ma" value="false"/>
                                    <c:set var="superintendence" value="false"/>  
                                    <c:set var="coo" value="false"/>
                                    <c:set var="topM" value="false"/>
                                    <c:forEach items="${actionBean.context.currentUser.roles}" var="i">
                                        <c:choose>
                                            <c:when test="${i.group.groupId eq '1'}">
                                                <c:set var="ma" value="true"/>
                                            </c:when>
                                            <c:when test="${i.group.groupId eq '2' or i.group.groupId eq '14' or i.group.groupId eq '15' or i.group.groupId eq '17'}">
                                                <c:set var="superintendence" value="true"/>
                                            </c:when>
                                            <c:when test="${i.group.groupId eq '3'}">
                                                <c:set var="admin" value="true"/>
                                            </c:when> 
                                            <c:when test="${i.group.groupId eq '4'}">
                                                <c:set var="coo" value="true"/>
                                            </c:when> 
                                            <c:when test="${i.group.groupId eq '9'}">
                                                <c:set var="topM" value="true"/>
                                            </c:when>
                                            <c:when test="${i.group.groupId eq '18'}">
                                                <c:set var="depH" value="true"/>
                                            </c:when>
                                            <c:when test="${i.group.groupId eq '24'}">
                                                <c:set var="sat" value="true"/>
                                            </c:when>
                                        </c:choose>

                                </c:forEach>
                                <c:if test="${admin}">
                                    <li class="${fn:contains(pageContext.request.requestURI, '/admin') ? 'current-menu-item' : ''}"><a href="">Manage User</a>
                                        <ul>                                           
                                            <li><a href="${pageContext.request.contextPath}/adminUser"><span>User</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/adminGroup"><span>Group</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/adminDepartment"><span>Department</span></a></li>
                                        </ul>
                                    </li>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/adminVessel') ? 'current-menu-item' : ''}"><a>Manage Vessel</a>
                                        <ul>                                           
                                            <li><a href="${pageContext.request.contextPath}/adminVessel"><span>Vessel</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/adminVesselGroup"><span>Vessel Group</span></a></li>
                                        </ul>
                                    </li>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/adminSeverity') ? 'current-menu-item' : ''}"><a>Code</a>
                                        <ul>                                           
                                            <li><a href="${pageContext.request.contextPath}/adminSeverity"><span>Severity Code</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/adminPriority"><span>Priority Code</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/adminRemark"><span>Status Remark Code</span></a></li>                                            
                                        </ul>
                                    </li>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/shipVisit3Admin') ? 'current-menu-item' : ''}"><a>Ship Visit</a>
                                        <ul>                                           
                                            <li><a href="${pageContext.request.contextPath}/shipVisit3Admin"><span>Main Header</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/shipVisit3Admin?viewSubHeader"><span>Additional Header</span></a></li>
                                            <li class="${fn:contains(pageContext.request.requestURI, '/shipVisit3Admin?viewMatch') ? 'current-menu-item' : ''}"><a><span>Matching</span></a>
                                                <ul style="width:14em">
                                                    <li><a  href="${pageContext.request.contextPath}/shipVisit3Admin?viewMatch"><span>For Header</span></a></li>
                                                    <li><a  href="${pageContext.request.contextPath}/shipVisit3Admin?viewSubMatch"><span>For Additional Header</span></a></li>
                                                </ul>
                                            </li>                                            
                                        </ul>
                                    </li>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/sessionManager') ? 'current-menu-item' : ''}"><a href="${pageContext.request.contextPath}/sessionManager">Session Manager</a></li>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/adminObs') ? 'current-menu-item' : ''}"><a>Observation</a>
                                        <ul>
                                            <li><a href="${pageContext.request.contextPath}/adminObs"><span>Task Status</span></a></li>
                                            <li><a href="${pageContext.request.contextPath}/adminObsStatus"><span>User Status</span></a></li>
                                        </ul>
                                    </li>
                                    
                                    </c:if>
                                    <c:if test="${!admin}">
                                        <c:if test="${ma || superintendence || coo || topM || depH || sat}">
                                        <li class="${fn:contains(pageContext.request.requestURI, '/observation') ? 'current-menu-item' : ''}"><a>Observation</a>
                                            <ul style="width:14em">
                                                <c:if test="${ma}">
                                                    <li><a href="${pageContext.request.contextPath}/observation"><span>New Observation Report</span></a></li>
                                                    <li><a href="${pageContext.request.contextPath}/observation?draftReportForm"><span>Draft Report</span></a></li>
                                                    <li><a href="${pageContext.request.contextPath}/observation?listReportForm"><span>List Report</span></a></li>
                                                    </c:if>
                                                    <c:if test="${superintendence}">
                                                    <li><a href="${pageContext.request.contextPath}/observation?superintendenceReportForm"><span>List Report</span></a></li>
                                                    </c:if>
                                                    <c:if test="${coo || topM || depH || sat}">
                                                    <li><a href="${pageContext.request.contextPath}/observation?listReportForm"><span>List Report</span></a></li>
                                                    </c:if>
                                                <li><a href="${pageContext.request.contextPath}/observation?closeReportForm"><span>Close Observation Report</span></a></li>
                                            </ul>
                                        </li>
                                    </c:if>

                                    <li class="${fn:contains(pageContext.request.requestURI, '/personal') ? 'current-menu-item' : ''}"><a>Personal Task</a>
                                        <ul style="width:17.5em">
                                            <c:if test="${!topM}">
                                                <c:if test="${coo}">
                                                    <li><a href="${pageContext.request.contextPath}/personalTask"><span>New Personal Task</span></a></li>
                                                    <li><a href="${pageContext.request.contextPath}/personalTask?list_task"><span>Open Personal Task</span></a></li>
                                                    <li><a href="personalTask?history_taskCoo"><span>Closed Personal Task</span></a></li>
                                                    </c:if>
                                                    <c:if test="${!coo}">
                                                    <li><a href="${pageContext.request.contextPath}/personalTask?inbox"><span>Open Personal Task</span></a></li>
                                                    <li><a href="personalTask?history_task"><span>Closed Personal Task</span></a></li>
                                                    </c:if>
                                                </c:if>
                                                <c:if test="${topM || ma}">
                                                <li><a href="${pageContext.request.contextPath}/personalTask?viewListOpenTask"><span>View Staff - Open Personal Task</span></a></li>
                                                <li><a href="personalTask?viewListCloseTask"><span>View Staff - Closed Personal Task</span></a></li>
                                                </c:if>
                                        </ul>
                                    </li>  

<%--                                    <li class="${fn:contains(pageContext.request.requestURI, '/visit') ? 'current-menu-item' : ''}"><a>Ship Visit</a>
                                        <ul>
                                            <c:if test="${!(coo || ma || topM)}">
                                                <li><a href="${pageContext.request.contextPath}/shipVisit"><span>New Visit</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit?viewListVisit"><span>List Visited</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit?searchPastVisitStaf"><span>Past Visited</span></a></li>
                                            </c:if>
                                            <c:if test="${coo || ma || topM}">
                                                <li><a href="${pageContext.request.contextPath}/shipVisit?mainStaffVisit"><span>List Staff Visited</span></a></li>
                                            </c:if>
                                        </ul>
                                    </li>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/shipVisitFlow') ? 'current-menu-item' : ''}"><a>Ship Visit</a>
                                        <ul>
                                            <c:if test="${!(coo || ma || topM)}">
                                                <li><a href="${pageContext.request.contextPath}/shipVisitFlow"><span>New Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisitFlow?visitKiv"><span>KIV Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisitFlow?visitApprove"><span>Approved Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisitFlow?visitReject"><span>Rejected Report</span></a></li>
                                                </c:if>
                                                <c:if test="${coo || ma || topM}">
                                                <li><a href="${pageContext.request.contextPath}/shipVisitFlow?staffVisitKIV"><span>Verify Staff Visit</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisitFlow?searchStaffVisit"><span>List Staff Visited</span></a></li>
                                                </c:if>
                                        </ul>
                                    </li>--%>
                                    <li class="${fn:contains(pageContext.request.requestURI, '/shipVisit3Flow') ? 'current-menu-item' : ''}"><a>Ship Visit</a>
                                        <ul>
                                            <c:if test="${!(coo || ma || topM)}">
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow"><span>New Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow?visitKiv"><span>Submitted Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow?visitApprove"><span>Approved Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow?visitReject"><span>Rejected Report</span></a></li>
                                                </c:if>
                                                <c:if test="${coo || ma || topM}">
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow"><span>New Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow?visitKiv"><span>Submitted Report</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow?staffKIV"><span>Verify Staff Visit</span></a></li>
                                                <li><a href="${pageContext.request.contextPath}/shipVisit3Flow?searchStaffVisit"><span>List Staff Visited</span></a></li>
                                                </c:if>
                                        </ul>
                                    </li>
                                </c:if>
                                <c:if test="${ma || coo || topM}">
                                    <li class="${fn:contains(pageContext.request.requestURI, '/report') ? 'current-menu-item' : ''}"><a href="${pageContext.request.contextPath}/report">Report</a>
                                    </li>
                                </c:if>
                            </c:if>
                            <li class="${fn:contains(pageContext.request.requestURI, '/gallery') ? 'current-menu-item' : ''}"><a href="${pageContext.request.contextPath}/gallery">Photo Gallery</a>
                            </li>
                            <li><a href="${pageContext.request.contextPath}/logout">Logout</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </c:if>

    <div id="main">
        <div class="wrapper">
            <div id="content">
                <c:if test="${!front && !home}">
                    <div class="right-align">
                        <span class="title"><b>User : ${actionBean.context.userId}</b></span>
                        <br>
                    </div>
                    <img src="${pageContext.request.contextPath}/images/loading_img.gif" style="display:none" id="loading-img"/>

                </c:if>
                <decorator:body />                    
            </div>
        </div>
    </div>
    <br>
    <br>
    <br>
    <script type="text/javascript">
        $(document).ready(function() {
//            alert(timerStartLoad);
            var currentDate2 = new Date();
            var timerEndLoad = currentDate2.getTime();
//            alert(timerEndLoad);
            var diff = (timerEndLoad - timerStartLoad) / 1000;
//            alert(diff);
            var mark = "\u00A9 2013 Marine Audit & Task System all rights reserved.";
            mark += " Best view this system by using mozilla firefox with resolution 1024 X 768.";
            mark += " This page was generated in : "+diff+" seconds.";
            $("#loadTimer").text(mark);
//            $("#loadTimer").text("This page was generated in : "+diff+" seconds");
        });
        
    </script>    
    <div id="bottom">
        <div class="wrapper">
            <div id="bottom-text"><div id="loadTimer"></div></div>
            <!--<div id="bottom-text">&copy; 2013 Marine Audit & Task System all rights reserved. Best view this system by using mozilla firefox with resolution 1024 X 768. <div id="loadTimer"></div></div>-->
        </div>
    </div>
</body>
</html>
